package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallCouponUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallCouponUserMapper {
    @Delete({
        "delete from haogoumall_coupon_user",
        "where coupon_user_id = #{couponUserId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer couponUserId);

    @Insert({
        "insert into haogoumall_coupon_user (coupon_user_id, user_id, ",
        "coupon_id, coupon_user_status, ",
        "coupon_user_used_time, coupon_user_start_time, ",
        "coupon_user_end_time, order_id, ",
        "coupon_user_add_time, coupon_user_update_time, ",
        "coupon_user_deleted)",
        "values (#{couponUserId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, ",
        "#{couponId,jdbcType=INTEGER}, #{couponUserStatus,jdbcType=SMALLINT}, ",
        "#{couponUserUsedTime,jdbcType=TIMESTAMP}, #{couponUserStartTime,jdbcType=TIMESTAMP}, ",
        "#{couponUserEndTime,jdbcType=TIMESTAMP}, #{orderId,jdbcType=INTEGER}, ",
        "#{couponUserAddTime,jdbcType=TIMESTAMP}, #{couponUserUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{couponUserDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallCouponUser record);

    @InsertProvider(type=HaogoumallCouponUserSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallCouponUser record);

    @Select({
        "select",
        "coupon_user_id, user_id, coupon_id, coupon_user_status, coupon_user_used_time, ",
        "coupon_user_start_time, coupon_user_end_time, order_id, coupon_user_add_time, ",
        "coupon_user_update_time, coupon_user_deleted",
        "from haogoumall_coupon_user",
        "where coupon_user_id = #{couponUserId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="coupon_user_id", property="couponUserId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.INTEGER),
        @Result(column="coupon_user_status", property="couponUserStatus", jdbcType=JdbcType.SMALLINT),
        @Result(column="coupon_user_used_time", property="couponUserUsedTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="coupon_user_start_time", property="couponUserStartTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="coupon_user_end_time", property="couponUserEndTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="order_id", property="orderId", jdbcType=JdbcType.INTEGER),
        @Result(column="coupon_user_add_time", property="couponUserAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="coupon_user_update_time", property="couponUserUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="coupon_user_deleted", property="couponUserDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallCouponUser selectByPrimaryKey(Integer couponUserId);

    @UpdateProvider(type=HaogoumallCouponUserSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallCouponUser record);

    @Update({
        "update haogoumall_coupon_user",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "coupon_id = #{couponId,jdbcType=INTEGER},",
          "coupon_user_status = #{couponUserStatus,jdbcType=SMALLINT},",
          "coupon_user_used_time = #{couponUserUsedTime,jdbcType=TIMESTAMP},",
          "coupon_user_start_time = #{couponUserStartTime,jdbcType=TIMESTAMP},",
          "coupon_user_end_time = #{couponUserEndTime,jdbcType=TIMESTAMP},",
          "order_id = #{orderId,jdbcType=INTEGER},",
          "coupon_user_add_time = #{couponUserAddTime,jdbcType=TIMESTAMP},",
          "coupon_user_update_time = #{couponUserUpdateTime,jdbcType=TIMESTAMP},",
          "coupon_user_deleted = #{couponUserDeleted,jdbcType=BIT}",
        "where coupon_user_id = #{couponUserId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallCouponUser record);
}